package com.lmf.annotation;

import com.lmf.annotation.config.MyConfigOfAutowired;
import com.lmf.annotation.controller.MyController;
import com.lmf.annotation.service.MyService;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 测试 自动装配注解 ：@Autowired
 */
public class IOCTest_BeanAutowired {
    @Test
    public void test_1(){
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfigOfAutowired.class);
        String[] strings = context.getBeanNamesForType(MyService.class);
        for (String string : strings) {
            System.out.println(string);
        }
        System.out.println("----------------------------");
        MyController bean = context.getBean(MyController.class);
        System.out.println(bean);
    }
}
